#include "modelcontainer.h"
#include <QDebug>

ModelContainer::ModelContainer(QObject *parent):
    QObject(parent)
{
    mp_town_model = new ApNavTreeModel(this);
    mp_apartments_model = new ApTableModel(this);
    mp_tenants_model = new TenantsModel(this);
    mp_family_model = new FamilyModel(this);
    mp_leases_model = new LeasesModel(this);
    mp_payments_model = new PaymentsModel(this);
    mp_bills = new BillsModel(this);
}


void ModelContainer::set_dbms(HousingDBMS *p_dbms)
{
    qDebug()<<"Model Container :: set_dbms *****************************************************";
    mp_dbms = p_dbms;

    mp_town_model->set_dbms(mp_dbms);
    mp_apartments_model->set_dbms(mp_dbms);
    mp_tenants_model ->set_dbms(mp_dbms);
    mp_family_model->set_dbms(mp_dbms);
    mp_leases_model ->set_dbms(mp_dbms);
    mp_payments_model->set_dbms(mp_dbms);
    mp_bills->set_dbms(mp_dbms);
}

void ModelContainer::load_data()
{
    qDebug()<<"Model Container :: load_data *****************************************************";
    mp_town_model->load_data();
    mp_apartments_model->load_data(mp_town_model->get_h_indexes());
    mp_tenants_model->load_data();
    mp_family_model->load_data(QVariant());
    mp_leases_model->load_data();
    mp_payments_model->load_data();
    mp_bills->load_data();
}
